package com.nuedu.corejava.ch10.homework;

import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;


public class HomeWork1 {
	public static void main(String[] args) {
		Set<Student> students = new HashSet<Student>();
		Student student1 = new Student(01, "mark", 10, "男");
		Student student2 = new Student(02, "mark1", 14, "女");
		Student student3 = new Student(03, "mark2", 20, "男");
		Student student4 = new Student(04, "mark3", 17, "女");
		students.add(student1);
		students.add(student2);
		students.add(student3);
		students.add(student4);
		
		/*//方法1：使用iterator进行遍历
		 * 
		 * Iterator<Student> iterator = students.iterator(); while (iterator.hasNext())
		 * { System.out.println((iterator.next()).toString());
		 * 
		 * }
		 */
		//使用for each进行遍历
		for (Student student : students) {
			System.out.println(student);
		}
	}

}
